<template>
	<view class="con">
		<identity-suc v-if="isJudge" @changeState="changeState"></identity-suc>
		<identity-fail :name="name" v-else @changeState="changeState"></identity-fail>
	</view>
</template>

<script>
	import identitySuc from './identity-child/identity-suc.vue'
	import identityFail from './identity-child/identity-fail.vue'

	import {
		judgeCheck,
		queryName
	} from '@/api/http/main/my/community.js'

	export default {
		components: {
			identitySuc,
			identityFail
		},
		data() {
			return {
				isJudge: false,
				name: ''
			}
		},
		methods: {
			//1，判断是否实名认证
			judgeCheck() {
				var that = this
				judgeCheck().then(res => {
					if (res.data.pubInfo.code !== 0) {
						that.isJudge = true
						console.log(123123)
						return uni.$showMsg(res.data.pubInfo.message);
					}
					if (res.data.busInfo === true) {
						//已实名
						that.isJudge = false
						that.queryName()
						uni.setStorageSync('identifyCheck', true)
					} else {
						that.isJudge = true
					}

				})
			},
			//修改状态
			changeState(e) {
				this.isJudge = e
			},
			queryName() {
				queryName().then(res => {
					if (res.data.pubInfo.code !== 0) {
						return uni.$showMsg(res.data.pubInfo.message);
					}
					this.name = res.data.busInfo
				})
			}
		},
		created() {
			this.judgeCheck()
		}

	}
</script>

<style scoped lang="scss">

</style>
